<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

		<!-- Metas -->
		<title>curtains.js | AJAX navigation example with plane removal</title>
		<meta name="description" content="Add and remove WebGL planes on AJAX page navigation with curtains.js" />
		<link rel="canonical" href="https://www.curtainsjs.com/examples/ajax-navigation-with-plane-removal/index.html" />

		<!-- Facebook OG -->
		<meta property="og:title" content="curtains.js | AJAX navigation example with plane removal">
		<meta property="og:type" content="website">
		<meta property="og:description" content="Add and remove WebGL planes on AJAX page navigation with curtains.js">
		<meta property="og:url" content="https://www.curtainsjs.com/examples/ajax-navigation-with-plane-removal/index.html">
		<meta property="og:image" content="https://www.curtainsjs.com/images/curtains-js-logo.jpg">

		<!-- Twitter card -->
		<meta name="twitter:card" content="summary_large_image">
		<meta name="twitter:site" content="@martinlaxenaire">
		<meta name="twitter:creator" content="@martinlaxenaire">
		<meta name="twitter:title" content="curtains.js | AJAX navigation example with plane removal">
		<meta name="twitter:description" content="Add and remove WebGL planes on AJAX page navigation with curtains.js">
		<meta name="twitter:image" content="https://www.curtainsjs.com/images/curtains-js-logo.jpg">

		<!-- Favicon -->
		<link rel="apple-touch-icon" sizes="180x180" href="../../../images/favicons/apple-touch-icon.png">
		<link rel="icon" type="image/png" sizes="32x32" href="../../../images/favicons/favicon-32x32.png">
		<link rel="icon" type="image/png" sizes="16x16" href="../../../images/favicons/favicon-16x16.png">
		<link rel="manifest" href="../../../images/favicons/site.webmanifest">
		<link rel="mask-icon" href="../../../images/favicons/safari-pinned-tab.svg" color="#202340">
		<link rel="shortcut icon" href="../../../images/favicons/favicon.ico">
		<meta name="msapplication-TileColor" content="#202340">
		<meta name="msapplication-config" content="../../../images/favicons/browserconfig.xml">
		<meta name="theme-color" content="#202340">

		<link href="https://fonts.googleapis.com/css?family=PT+Sans:400,700" rel="stylesheet">
		<link href="https://fonts.googleapis.com/css?family=Abril+Fatface" rel="stylesheet">
		<link rel="stylesheet" href="style.css" type="text/css">
	</head>
	<body>
        <div id="page-wrap">

			<div id="canvas"></div>

			<a href="https://www.curtainsjs.com/" title="back to curtains.js website" id="back-to-lib-link" target="_blank">back to curtains.js website</a>

            <a href="https://github.com/martinlaxenaire/curtainsjs/blob/master/examples/ajax-navigation-with-plane-removal/js/ajax.nav.setup.js" title="Show source code" id="source-code-link" target="_blank">&lt;/ &gt;</a>

			<div class="wrapper">
				<nav id="navigation">
					<a class="navigation-button active" href="index.html">
						Home
					</a>
					<a class="navigation-button" href="archive1.html">
						Archive 1
					</a>
					<a class="navigation-button" href="archive2.html">
						Archive 2
					</a>
				</nav>
			</div>

			<div id="content">

				<div class="wrapper">
					<h1>This is the homepage</h1>
					<div>
						<h2>Removing and adding planes at each AJAX call</h2>
						<p>
							Sometimes, you may want to use curtains.js with an ajax navigation. Thanks to the removePlane() method there's an easy way to achieve it.<br/>
							The idea is to delete the planes just before each AJAX call and to add new planes just after we'd get the AJAX response.
						</p>
						<p>
							After initialising our main Curtains object on window load, this is what happens when you click on a menu link above:
						</p>
						<ol>
							<li>
								Get the link href and send an AJAX call
							</li>
							<li>
								Once we got the response, remove all the existing planes via the removePlane() method, set a timeout (useful to animate page transitions) and append the new content
							</li>
							<li>
								After the content has been appended, add the new planes via the addPlane() method if needed
							</li>
						</ol>
						<h3>Pros</h3>
						<ul>
							<li>
								Clean code and SEO friendly markup
							</li>
							<li>
								Perfect to use with SPA frameworks like React, Vue or Angular (or with your own custom AJAX navigation script)
							</li>
						</ul>
						<h3>Cons</h3>
						<ul>
							<li>
								Can cause a small delay before appearing, mostly due to images (or other assets) loading time
							</li>
						</ul>

					</div>
				</div>

			</div>
		</div>

        <script src="js/ajax.nav.setup.js" type="module"></script>

		<!-- Global site tag (gtag.js) - Google Analytics -->
		<script async src="https://www.googletagmanager.com/gtag/js?id=UA-141413267-1"></script>
		<script>
		  	window.dataLayer = window.dataLayer || [];
		  	function gtag(){dataLayer.push(arguments);}
		  	gtag('js', new Date());

		  	gtag('config', 'UA-141413267-1');
		</script>

	</body>
</html>
